<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>

        <style>
            #d{
                width: 100px;
                height: 100px;
                background-color: #ff00ff;
                position: relative;
            }
        </style>

        <script>

            function f1(){
                // window.open();
                var win=open("1.html","w1","width=400,height=400,left=30,top=30");

                // window.close();
                setTimeout(function(){
                    win.close();
                },5000);

            }

            function f2(){
                var intervalId=setInterval(move,30);

                setTimeout(function(){
                    clearInterval(intervalId);
                },3000);
            }

            function move(){
                var obj=document.getElementById("d");
                obj.style.left=parseInt(obj.style.left)+5+"px";
            }

        </script>

    </head>
    <body onload="f2();">
        <a href="javascript:;" onclick="f1();">打开</a>

        <a href="javascript:;" onclick="move();">移动</a>

        <div id="d" style="left: 0px;"></div>
    </body>
</html>